<template>
    <div>
        <!-- <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button> -->
        <el-dialog
        :title="$t('salesManage.confirmationRecycling')"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose">
        <div>
        <ul>
            <li>
                <div>{{$t('salesManage.achievementRate')}}：{{data.rate}}</div>
            </li>
            <li>
                <div>{{$t('salesManage.manualNub')}}：{{data.artificialCount}}</div>
            </li>
            <li>
                <div>{{$t('salesManage.robotNub')}}：{{data.robotAgreeCount}}</div>
            </li>
            <li>
                <div>{{$t('salesManage.totalUsers')}}：{{data.totalCount}}</div>
            </li>
        </ul>    
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirm">确 定</el-button>
        </span>
        </el-dialog>
    </div>
</template>

<script>
  export default {
    data() {
      return {
        dialogVisible: false,
        data:{},
        rowData:{
            batchCode:'',
            importId:''
        }
      };
    },
    methods: {
        showDialog(row){
            this.rowData = {
                batchCode: row.batchCode,
                importId: row.id
            }
            let params = {
                batchCode:row.batchCode
            };
            this.$api.telSales.getUserDetailByBatchCodeRobot(params).then((res) => {
                const { status, data, error } = res;
                if (status === '1' && error === '00000000') {
                    this.dialogVisible = true;
                    this.data = data
                }
            });
        },
        confirm(){
            const params = {
                ...this.rowData,
                isRobot:true
            };
            this.$api.telSales.recyclingUser(params).then((res) => {
                const { status, data, error } = res;
                if (status === '1' && error === '00000000') {
                    this.dialogVisible = false;
                    this.$message.success(this.$tc('salesManage.successfulRecovery'));
                    this.$emit('recoverySuc')
                }
            });
        },
        handleClose(done) {
            this.$confirm('确认关闭？')
            .then(_ => {
                done();
            })
            .catch(_ => {});
        }
    }
  };
</script>